'use strict';

module.exports = function countSameElements(collection) {
  let arr = [];
  for(let i = 0; i < collection.length;){
    let count = 0;
    for(let j = i; j < collection.length; j++){
      if (collection[i] === collection[j]) {
        count++;
      }
    }
    arr.push({
      key: collection[i],
      count: count
    })
    i+=count;
  }
  return arr;
}

